<template>
	<view>
		<unicloud-db collection="carList" v-slot:default="{ data }">
			<view class="" v-for="(item, index) in data" :key="index">
				<image :src="item.image" mode=""></image>
				<button @click="add(item)">+</button>
				<text>{{ item.count }}</text>
				<button>-</button>
			</view>
		</unicloud-db>
	</view>
</template>

<script>
	export default {
		methods: {
			async add(item) {
				item.count++
				await uniCloud.callFunction({
					name: 'add_to_car_list',
					data: {
						item: item
					}
				})

			}
		}
	}
</script>